﻿using UnityEngine;
using UnityEngine.Scripting;
using System.Runtime.Serialization;

namespace GMME.Model.Rtm.Notify
{
    [DataContract]
    [Preserve]
    public class RtmChannelHistoryMessageNotify : ReceiveRtmChannelMessageNotify
    {
#if UNITY_ANDROID
        internal static RtmChannelHistoryMessageNotify ConvertRtmChannelHistoryMessage(
            AndroidJavaObject javaObject)
        {
            if (javaObject != null)
            {
                RtmChannelHistoryMessageNotify rtmChannelHistoryMessage = new();
                rtmChannelHistoryMessage.ChannelId = javaObject.Call<string>("getChannelId");

                rtmChannelHistoryMessage.ServerMsgId = javaObject.Call<string>("getServerMsgId");
                rtmChannelHistoryMessage.ClientMsgId = javaObject.Call<string>("getClientMsgId");
                rtmChannelHistoryMessage.Timestamp = javaObject.Call<long>("getTimestamp");
                rtmChannelHistoryMessage.SenderId = javaObject.Call<string>("getSenderId");
                rtmChannelHistoryMessage.IsFromOpenApi = javaObject.Call<bool>("isFromOpenApi");


                rtmChannelHistoryMessage.MessageType = javaObject.Call<int>("getMessageType");
                rtmChannelHistoryMessage.MessageString = javaObject.Call<string>("getMessageString");
                rtmChannelHistoryMessage.MessageBytes = javaObject.Call<byte[]>("getMessageBytes");

                return rtmChannelHistoryMessage;
            }

            return null;
        }
#endif
    }
}